from django.contrib import admin
from models import MainWord, DefinitionPartOfSpeech, WordUsage

class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'publisher', 'publication_date',)
    list_filter = ('publication_date',)
    date_hierarchy = 'publication_date'
    ordering = ('-publication_date',)

    # ///// from BaseModelAdmin
    raw_id_fields = ('publisher',)
    fields = ('title', 'authors', 'publisher', 'publication_date',) # Q: How do you know whether this will affect listing page or form page???
    #exclude = None
    #fieldsets = None
    #form = forms.ModelForm
    #tuple filter_vertical = ()
    filter_horizontal = ('authors',)
    #dictionary radio_fields = {}
    #dictionary prepopulated_fields = {}


class MainWordAdmin(admin.ModelAdmin):
    list_display = ('word', 'pronunciation',)
    #list_display_links = ('last_name', 'email',)
    search_fields = ('word',)
    #list_filter = ('last_name', 'email',)
    list_select_related = True
#int list_per_page = 100
#   date_hierarchy = None
    save_as = False
#   save_on_top = False
#   ordering = None
#    inlines = [BookAdmin]
#   change_form_template = None
# change_list_template = None
# delete_confirmation_template = None
# object_history_template = None
#tuple add_view = transaction.commit_on_success(add_view)
#tuple change_view = transaction.commit_on_success(change_view)


class DefinitionPartOfSpeechAdmin(admin.ModelAdmin):
    list_display = ('word_fk', 'part_of_speech', 'part_of_speech_alt')
    raw_id_fields = ('word_fk',)
    #filter_horizontal = ('word_fk',)

class WordUsageAdmin(admin.ModelAdmin):
    list_display = ('part_of_speech_fk', 'main_definition', 'vietnamese_phrase', 'english_phrase', 'synonym', 'antonym', 'sino_vietnamese', 'restricted', 'noun_classifier',)

admin.site.register(MainWord, MainWordAdmin)
admin.site.register(DefinitionPartOfSpeech, DefinitionPartOfSpeechAdmin)
admin.site.register(WordUsage, WordUsageAdmin)
